<?php

namespace Summer\Hjd\Http\Controllers;

use Illuminate\Routing\Controller;
use RainLab\User\Models\User as UserModel;

class OrgChartController extends Controller
{

    public function tuijianchildren($nid=null)
    {
        $res=[];
        $children_list=UserModel::where(['tuid'=>$nid])->orderBy('id')->get();
        foreach ($children_list as $clv){
            $datascource['id']=strval($clv['id']);//这里要用字符串
            $datascource['name']=$clv['username'];
            $datascource['title']=$clv['userphone']."<br>".$clv['realname'];

            $clv_count=UserModel::where(['tuid'=>$clv['id']])->count();
            if($clv_count>0){
                $datascource['relationship']="001";
            }else{
                $datascource['relationship']="000";
            }
            $res['children'][]=$datascource;
        }
        return $res;
    }
}